package comday05.itheima03;

import java.util.Arrays;
import java.util.Random;

public class Demo09 {

    public static void main(String[] args) {
        //调用方法,获取到数组
        int[] arr1 = getArr();
        System.out.println(Arrays.toString(arr1));

        int[] arr2 = getArr();
        System.out.println(Arrays.toString(arr2));
    }


    //定义方法,生成一个包含5个随机数的数组并返回,随机数1-100之间
    public static int[] getArr(){
        //创建随机数对象
        Random r = new Random();
        //创建数组
        int[] arr = new int[5];
        //循环生成随机数给数组赋值
        for (int i = 0; i < arr.length; i++) {
            int a = r.nextInt(100)+1;
            arr[i] = a;
        }

        return arr;
    }
}
